package ch.fusun.baron.basic.client.ui.player;

import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.swt.SWT;

import ch.fusun.baron.basic.command.ProposeMarriageCommand;
import ch.fusun.baron.client.rmi.ClientService;
import ch.fusun.baron.core.injection.ReInjector;

/**
 * Opens the marriage proposal dialog
 */
public class ProposeMarriageHandler extends AbstractHandler {

	@Override
	public Object execute(ExecutionEvent event) throws ExecutionException {
		MarriageProposalDialog dialog = new MarriageProposalDialog();
		if (dialog.open() == SWT.OK) {
			ClientService client = ReInjector.getInstance()
					.getInstanceForClass(ClientService.class);
			client.execute(new ProposeMarriageCommand(dialog.getProposer(),
					dialog.getProposedTo()));
		}
		return null;
	}
}
